<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickevents.cpp -->
  <title>PointerEvent QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >PointerEvent QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">PointerEvent QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$PointerEvent-brief -->
<p>Provides information about an event from a pointing device. <a href="#details">更多...</a></p>
<!-- @@@PointerEvent -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr></table></div><ul>
<li><a href="qml-qtquick-pointerevent-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-pointerevent.html#button-prop">button</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerevent.html#buttons-prop">buttons</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerevent.html#device-prop">device</a></b></b> : PointerDevice</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerevent.html#modifiers-prop">modifiers</a></b></b> : int</li>
</ul>
<!-- $$$PointerEvent-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p>A <a href="qml-qtquick-pointerevent.html">PointerEvent</a> is an event describing contact or movement across a surface, provided by a mouse, a touchpoint (single finger on a touchscreen), or a stylus on a graphics tablet. The <a href="qml-qtquick-pointerevent.html#device-prop">device</a> property provides more information about where the event came from.</p>
<p class="centerAlign"><img src="images/touchpoint-metrics.png" alt="" /></p><p><b>See also </b><a href="qml-qtquick-pointerhandler.html">PointerHandler</a>.</p>
<!-- @@@PointerEvent -->
<h2>属性文档</h2>
<!-- $$$button -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="button-prop">
<td class="tblQmlPropNode"><p>
<a name="button-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">button</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the <a href="../qtcore/qt.html#MouseButton-enum">button</a> that caused the event, if any. If the <a href="qml-qtquick-pointerevent.html#device-prop">device</a> does not have buttons, or the event is a hover event, it will be <code>Qt.NoButton</code>.</p>
</div></div><!-- @@@button -->
<br/>
<!-- $$$buttons -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="buttons-prop">
<td class="tblQmlPropNode"><p>
<a name="buttons-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">buttons</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the combination of mouse or stylus <a href="../qtcore/qt.html#MouseButton-enum">buttons</a> pressed when the event was generated. For move events, this is all buttons that are pressed down. For press events, this includes the button that caused the event, as well as any others that were already held. For release events, this excludes the button that caused the event.</p>
</div></div><!-- @@@buttons -->
<br/>
<!-- $$$device -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="device-prop">
<td class="tblQmlPropNode"><p>
<a name="device-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">device</span> : <span class="type"><a href="qml-qtquick-pointerdevice.html">PointerDevice</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the device that generated the event.</p>
</div></div><!-- @@@device -->
<br/>
<!-- $$$modifiers -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="modifiers-prop">
<td class="tblQmlPropNode"><p>
<a name="modifiers-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">modifiers</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the <a href="../qtcore/qt.html#KeyboardModifier-enum">keyboard modifier</a> flags that existed immediately before the event occurred.</p>
<p>It contains a bitwise combination of the following flags:</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>Qt.NoModifier</code></td><td class="topAlign">No modifier key is pressed.</td></tr>
<tr><td class="topAlign"><code>Qt.ShiftModifier</code></td><td class="topAlign">A Shift key on the keyboard is pressed.</td></tr>
<tr><td class="topAlign"><code>Qt.ControlModifier</code></td><td class="topAlign">A Ctrl key on the keyboard is pressed.</td></tr>
<tr><td class="topAlign"><code>Qt.AltModifier</code></td><td class="topAlign">An Alt key on the keyboard is pressed.</td></tr>
<tr><td class="topAlign"><code>Qt.MetaModifier</code></td><td class="topAlign">A Meta key on the keyboard is pressed.</td></tr>
<tr><td class="topAlign"><code>Qt.KeypadModifier</code></td><td class="topAlign">A keypad button is pressed.</td></tr>
</table></div>
<p>For example, to react to a Shift key + Left mouse button click:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
          <span class="name">onTapped</span>: {
              <span class="keyword">if</span> ((<span class="name">event</span>.<span class="name">button</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">LeftButton</span>) <span class="operator">&amp;&amp;</span> (<span class="name">event</span>.<span class="name">modifiers</span> <span class="operator">&amp;</span> <span class="name">Qt</span>.<span class="name">ShiftModifier</span>))
                  <span class="name">doSomething</span>();
          }
      }
  }

</pre>
</div></div><!-- @@@modifiers -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
